#include <ros/ros.h>
#include <rts_database_pysrv/RTSDatabasePysrv.h>
#include <unistd.h>

int main(int argc, char **argv)
{
  sleep(5); // 必须等待服务起来再调用它

  ros::init(argc, argv, "rts_database_pysrv_cppnode");
  ros::NodeHandle nh;

  // 创建一个Service客户端
  ros::ServiceClient client = nh.serviceClient<rts_database_pysrv::RTSDatabasePysrv>("rts_database_pysrv");

  // 创建一个请求对象
  rts_database_pysrv::RTSDatabasePysrv srv;
  srv.request.a = 3;
  srv.request.b = 2;

  // 调用Service并等待响应
  if (client.call(srv))
  {
    ROS_INFO("Result: %ld", srv.response.result);
  }
  else
  {
    ROS_ERROR("Failed to call service");
    std::cout << client.call(srv) << std::endl;
    return 1;
  }

  return 0;
}